home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 December / PCWorld_2007-12_cd.bin / v cisle / htttrack / httrack-3.41-3.exe / {app} / src_win / WinHTTrack / Infoend.cpp < prev    next >
C/C++ Source or Header  |  2006-08-15  |  8KB  |  299 lines

  1. // infoend.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Shell.h"
  6. #include "infoend.h"
  7. #include "iplog.h"
  8. #include "NewProj.h"
  9.  
  10. extern CNewProj* dialog0;
  11. extern "C" {
  12.   #include "HTTrackInterface.h"
  13.   //#include "htsbase.h"
  14.   HTS_INLINE int fspc(FILE* fp,const char* type);
  15. }
  16.  
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. extern HICON httrack_icon;
  23.  
  24. #include "winhttrack.h"
  25. extern CWinHTTrackApp* this_app;
  26.  
  27. #include "inprogress.h"
  28. extern Cinprogress* inprogress;
  29.  
  30. /* Externe C */
  31. extern "C" {
  32.   #include "HTTrackInterface.h"
  33. };
  34.  
  35. // Helper
  36. extern LaunchHelp* HtsHelper;
  37.  
  38. /* Main splitter frame */
  39. #include "DialogContainer.h"
  40. #include "splitter.h"
  41. extern CSplitterFrame* this_CSplitterFrame;
  42.  
  43. /* Main WizTab frame */
  44. #include "WizTab.h"
  45. extern CWizTab* this_CWizTab;
  46. extern CWizTab* this_intCWizTab2;
  47.  
  48. /* Objet lui mΩme */
  49. Cinfoend* this_Cinfoend=NULL;
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // Cinfoend dialog
  53.  
  54. IMPLEMENT_DYNCREATE(Cinfoend, CPropertyPage)
  55.  
  56. Cinfoend::Cinfoend()
  57.     : CPropertyPage(Cinfoend::IDD)
  58. {
  59.   this_Cinfoend=this;
  60.     //{{AFX_DATA_INIT(Cinfoend)
  61.     //}}AFX_DATA_INIT
  62. }
  63.  
  64. Cinfoend::~Cinfoend() {
  65.   this_Cinfoend=NULL;
  66. }
  67.  
  68. void Cinfoend::DoDataExchange(CDataExchange* pDX)
  69. {
  70.     CPropertyPage::DoDataExchange(pDX);
  71.     //{{AFX_DATA_MAP(Cinfoend)
  72.     //}}AFX_DATA_MAP
  73. }
  74.  
  75.  
  76. BEGIN_MESSAGE_MAP(Cinfoend, CPropertyPage)
  77.     //{{AFX_MSG_MAP(Cinfoend)
  78.     ON_BN_CLICKED(IDlog, Onlog)
  79.     ON_BN_CLICKED(IDbrowse, Onbrowse)
  80.     ON_WM_HELPINFO()
  81.     ON_WM_TIMER()
  82.     ON_WM_DESTROY()
  83.     //}}AFX_MSG_MAP
  84.   ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  85.   ON_COMMAND(ID_HELP_FINDER,OnHelpInfo2)
  86.   ON_COMMAND(ID_HELP,OnHelpInfo2)
  87.     ON_COMMAND(ID_DEFAULT_HELP,OnHelpInfo2)
  88. END_MESSAGE_MAP()
  89.  
  90. /////////////////////////////////////////////////////////////////////////////
  91. // Cinfoend message handlers
  92.  
  93. BOOL Cinfoend::OnInitDialog() 
  94. {
  95.   UpdateData(false);      // force to call DoDataExchange
  96.  
  97.     //CPropertyPage::OnInitDialog();
  98.     
  99.   SetIcon(httrack_icon,false);
  100.   SetIcon(httrack_icon,true);  
  101.   EnableToolTips(true);     // TOOL TIPS
  102.   SetForegroundWindow();   // yop en premier plan!
  103.  
  104.   // Patcher l'interface pour les Franτais ;-)
  105.   if (LANG_T(-1)) {    // Patcher en franτais
  106.     //SetDlgItemTextCP(this, ,"");
  107.     //SetWindowTextCP(this, LANG(LANG_D6) /*"Fin du miroir"*/);
  108.     SetDlgItemTextCP(this, IDlog,LANG(LANG_D7) /*"Voir fichier d'audit"*/);
  109.     SetDlgItemTextCP(this, IDbrowse,LANG(LANG_D8) /*"Lancer Web"*/);
  110.     SetDlgItemTextCP(this_CWizTab, IDCANCEL,LANG_QUIT);
  111.     //SetDlgItemTextCP(this, IDC_NewProject,LANG_D9);
  112.     //SetDlgItemTextCP(this, IDOK,LANG_OK);
  113.   }
  114.  
  115.   int error = HTS_STAT.stat_errors;
  116.   if (error) {
  117.     SetDlgItemTextCP(this, IDlog,LANG_O14);
  118.     tm=SetTimer(WM_TIMER,250,NULL);
  119.   }
  120.  
  121.     return TRUE;
  122. }
  123.  
  124. void Cinfoend::Onlog() 
  125. {
  126.     char catbuff[CATBUFF_SIZE];
  127.   char pathlog[HTS_URLMAXSIZE*2];
  128.   strcpybuff(pathlog,dialog0->GetPath());
  129.   Ciplog form;
  130.   if (strlen(pathlog)>0)
  131.   if ((pathlog[strlen(pathlog)-1]!='/') && (pathlog[strlen(pathlog)-1]!='\\'))
  132.     strcatbuff(pathlog,"/");
  133.   // fichier log existe ou on est tΘlΘcommandΘ par un !
  134.   if ( (fexist(fconcat(catbuff,pathlog,"hts-err.txt"))) || (fexist(fconcat(catbuff,pathlog,"hts-log.txt"))) ) {
  135.     strcpybuff(form.pathlog,pathlog);
  136.     form.DoModal();
  137.   } else {
  138.     char s[HTS_URLMAXSIZE*2];
  139.     sprintf(s,LANG(LANG_D1 /*"No log files in %s!"*/ ),pathlog);
  140.     AfxMessageBox(s,MB_OK+MB_ICONEXCLAMATION);
  141.   }
  142. }
  143.  
  144. void Cinfoend::Onbrowse() 
  145. {
  146.     char catbuff[CATBUFF_SIZE];
  147.   char pathlog[HTS_URLMAXSIZE*2];
  148.   strcpybuff(pathlog,dialog0->GetPath());
  149.   if (strlen(pathlog)==0)
  150.     strcpybuff(pathlog,dialog0->GetPath());
  151.   Ciplog form;
  152.   if (strlen(pathlog)>0)
  153.   if ((pathlog[strlen(pathlog)-1]!='/') && (pathlog[strlen(pathlog)-1]!='\\'))
  154.     strcatbuff(pathlog,"\\");
  155.   if ( fexist(fconcat(catbuff,pathlog,"index.html")) ) {
  156.     ShellExecute(this->m_hWnd,"open",fconcat(catbuff,pathlog,"index.html"),"","",SW_RESTORE);    
  157.   } else {
  158.     char s[HTS_URLMAXSIZE*2];
  159.     sprintf(s,LANG(LANG_D2 /*"No index.html file in %s!"*/ ),pathlog);
  160.     AfxMessageBox(s,MB_OK+MB_ICONEXCLAMATION);
  161.   }
  162. }
  163.  
  164.  
  165.  
  166. // ------------------------------------------------------------
  167. // TOOL TIPS
  168. //
  169. // ajouter dans le .cpp:
  170. // remplacer les deux Wid1:: par le nom de la classe::
  171. // dans la message map, ajouter
  172. // ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  173. // dans initdialog ajouter
  174. // EnableToolTips(true);     // TOOL TIPS
  175. //
  176. // ajouter dans le .h:
  177. // char* GetTip(int id);
  178. // et en generated message map
  179. // afx_msg BOOL OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
  180. BOOL Cinfoend::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
  181. {
  182.   TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
  183.   UINT_PTR nID =pNMHDR->idFrom;
  184.   if (pTTT->uFlags & TTF_IDISHWND)
  185.   {
  186.     // idFrom is actually the HWND of the tool
  187.     nID = ::GetDlgCtrlID((HWND)nID);
  188.     if(nID)
  189.     {
  190.       char* st=GetTip((int)nID);
  191.       if (st != "") {
  192.         pTTT->lpszText = st;
  193.         pTTT->hinst = AfxGetResourceHandle();
  194.         return(TRUE);
  195.       }
  196.     }
  197.   }
  198.   return(FALSE);
  199. }
  200. char* Cinfoend::GetTip(int ID)
  201. {
  202.   switch(ID) {
  203.     case IDOK:     return LANG(LANG_D3 /*"Click to quit WinHTTrack"*/ ); break;
  204.     case IDlog:    return LANG(LANG_D4 /*"View log files"*/ ); break;
  205.     case IDbrowse: return LANG(LANG_D5 /*"Browse html start page"*/ ); break;
  206.     //case : return ""; break;
  207.   }
  208.   return "";
  209. }
  210. // TOOL TIPS
  211. // ------------------------------------------------------------
  212.  
  213.  
  214.  
  215. // Appel aide
  216. void Cinfoend::OnHelpInfo2() {
  217.   (void) OnHelpInfo(NULL);
  218. }
  219.  
  220. BOOL Cinfoend::OnHelpInfo(HELPINFO* dummy) 
  221. {
  222.   //return CPropertyPage::OnHelpInfo(pHelpInfo);
  223.   HtsHelper->Help("step5.html");
  224.   return true;
  225.   //AfxGetApp()->WinHelp(0,HELP_FINDER);    // Index du fichier Hlp
  226.   //return true;
  227. }
  228.  
  229. void Cinfoend::OnBye() 
  230. {
  231.   //this_CSplitterFrame->SetNewView(0,1,RUNTIME_CLASS(CDialogContainer));    
  232.   // // // this_CWizTab2->DestroyWindow(); // crash!!
  233.  
  234.   //delete this_intCWizTab2->m_tabprogress;  // agh..
  235.   //this_intCWizTab2->m_tabprogress=NULL; inprogress=NULL; this_app->m_tabprogress=NULL;    // re agh..
  236.  
  237.   /* tout effacer */
  238.   //##while(this_intCWizTab2->GetPageCount()>0)
  239.   //##  this_intCWizTab2->RemovePage(0);
  240.   
  241.   //##this_intCWizTab2=NULL;
  242.   GetMainWindow()->SendMessage(WM_COMMAND,wm_ViewRestart,0);
  243. }
  244.  
  245. BOOL Cinfoend::OnQueryCancel( ) {
  246.   //if (AfxMessageBox(LANG(LANG_J1),MB_OKCANCEL)==IDOK) {
  247.   /* Envoyer un WM_CLOSE α notre fenΩtre principale */
  248.   GetMainWindow()->SendMessage(WM_CLOSE,0,0);
  249.   //}
  250.   return FALSE;
  251. }
  252.  
  253. BOOL Cinfoend::OnSetActive( ) {
  254.   // dΘtruire ICI sinon crash!!!!
  255.   WHTT_LOCATION("Infoend");
  256.   if (this_intCWizTab2) {
  257.     this_intCWizTab2->DestroyWindow();
  258.     delete this_intCWizTab2;
  259.     this_intCWizTab2=NULL;
  260.   }
  261.  
  262.   this_CWizTab->SetWizardButtons(PSWIZB_FINISH);
  263.   SetWindowTextCP(this_app->GetMainWnd(), LANG_F18b);
  264.   SetDlgItemTextCP(this_CWizTab, IDCANCEL,LANG_QUIT);
  265.   return 1;
  266. }
  267.  
  268. BOOL Cinfoend::OnWizardFinish( ) {
  269.   OnBye();
  270.     return 0;
  271. }
  272.  
  273.  
  274. void Cinfoend::OnTimer(UINT nIDEvent) 
  275. {
  276.   static wflag=FALSE;
  277.  
  278.   wflag=!wflag;
  279.  
  280.   CWnd* wnd=GetDlgItem(IDlog);
  281.   if (wnd) {
  282.     CString st="";
  283.     if (wflag)
  284.       st=LANG_O14;
  285.     SetDlgItemTextCP(this, IDlog,st);
  286.   }
  287.   
  288.     CPropertyPage::OnTimer(nIDEvent);
  289. }
  290.  
  291. void Cinfoend::OnDestroy() 
  292. {
  293.   if (tm!=0) {
  294.     KillTimer(tm); 
  295.     tm=-1; 
  296.   }
  297.     CPropertyPage::OnDestroy();
  298. }
  299.